import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

class MyJPanel extends JPanel
{
  private static final long serialVersionUID = 1L;
  private JLabel host, port, contentbase;
  private JComboBox hostCb;
  private JTextField portTf, contentbaseTf;
  private JButton status;

  MyJPanel(MyJLayeredPane mjp, MyJFrame frame)
  {
	System.out.println("MyJPanel, MyJPanel(MyJLayeredPane mjp)");
    this.setLayout(new FlowLayout());
    this.setBounds(0, 0, 800, 40);
    
    host = new JLabel("host");
    host.setForeground(Color.BLUE);
    add(host);
    
    hostCb = new JComboBox(mjp.getControl().getInetAddresses());
    hostCb.setPreferredSize(new Dimension(200, 25));
    hostCb.addItemListener(mjp.getControl());
    add(hostCb);
    
    port = new JLabel("port");
    port.setForeground(Color.BLUE);
    add(port);
    
    portTf = new JTextField("80");
    portTf.setPreferredSize(new Dimension(50, 25));
    portTf.addActionListener(mjp.getControl());
    add(portTf);
    
    contentbase = new JLabel("contentbase");
    contentbase.setForeground(Color.BLUE);
    add(contentbase);
    
    contentbaseTf = new JTextField(System.getProperty("user.dir"));
    contentbaseTf.setPreferredSize(new Dimension(300, 25));
    contentbaseTf.addActionListener(mjp.getControl());
    add(contentbaseTf);
    
    status = new JButton("start");
    status.setBackground(Color.green);
    status.setPreferredSize(new Dimension(70, 24));
    status.addActionListener(frame);
    add(status);
  }

  public void changeStatusBtn()
  {
	//System.out.println("MyJPanel, changeStatusBtn()");
    if (status.getText() == "start")
    {
      status.setBackground(Color.red);
      status.setText("stop");
    }
    else
    {
      status.setBackground(Color.green);
      status.setText("start");
    }
    repaint();
  }
  
  public void finalize() throws Throwable
  {
	System.out.println("MyJPanel, finalize()");
  }
  
  public String toString()
  {
	System.out.println("MyJPanel, toString()");
	return "[JPanel]";
  }
}